-
-
Notifications
You must be signed in to change notification settings - Fork 31
Faster flonum operations using flbit-field
#116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
f7002cd to
75ef5da
Compare
|
You might wonder why we need to micro-optimize this stuff and the answer is that this is something like 2% of all Herbie allocations. Working on the PR. |
75ef5da to
cd459c6
Compare
|
The require/typed will be pretty slow here, we should just fix that in TR directly. |
|
How does one do that? In theory there's an unsound version of |
|
You'd want to add it somewhere around here: https://github.com/racket/typed-racket/blob/c08e1a4fbbb6382d71fe3f4cc9362c6d588f71ef/typed-racket-lib/typed-racket/base-env/base-env-numeric.rkt#L2005 |
|
Done in racket/typed-racket#1484. How do we typically do this? Do we merge that and then remove the |
|
We should just merge the TR PR (possibly with a version bump) and then merge this one without the We could also add an optimization to transform |
|
Yeah, I couldn't (in a cursory look) figure out how the optimization stuff worked so I didn't touch that, but yes, in practice they'll always be constants so one could detect the results and optimize. In theory you could also detect constants and use that for type checking (to assert that it's an Index if the bounds are tight enough), dunno if that gets you anything but maybe. |
Racket 8.15 added
flbit-field, which can extract specific bits of a floating-point number as an integer. This allocates less than going through a byte-vector—it doesn't need to allocate at all, depending on how many bits you need—so the math library should use it. Specifically, this PR adds:flbit-fieldinflonum->ordinalandflonum->bit-field, which avoids allocating an intermediate byte-vector and going straight to an integerflbit-fieldinflonum->fields, which means thatflonum->sig+expno longer allocates at allflonums-betweenthat avoids any allocation if the output is a fixnum